<?php

use dosamigos\datepicker\DatePicker;
use yii\helpers\Html;
//use yii\grid\GridView;
use backend\models\EduEnterOrder;
use kartik\grid\GridView;
use kartik\export\ExportMenu;

/* @var $this yii\web\View */
/* @var $searchModel backend\models\EduEnterOrderSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = '入驻订单表';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="edu-enter-order-index">

    <h1><?= Html::encode($this->title) ?></h1>
    <?php // echo $this->render('_search', ['model' => $searchModel]); ?>

    <!--    <p>-->
    <!--        --><? //= Html::a('Create Edu Enter Order', ['create'], ['class' => 'btn btn-success']) ?>
    <!--    </p>-->

    <?php
    $gridColumns = [
        'gift.title',
        'out_trade_no',
        'gift.price',
        'count',
        'user.nickname',
        'create_time:datetime',
        [
            'attribute' => 'status',
            'value' => 'statusValue',
        ],
        'total_fee',
    ];

    echo ExportMenu::widget([
        'dataProvider' => $dataProvider,
        'columns' => $gridColumns,
        'filename' => '入驻订单',
        'columnSelectorOptions' => [
            'label' => '选择字段',
        ],

        'exportConfig' => [
            ExportMenu::FORMAT_TEXT => false,
            ExportMenu::FORMAT_PDF => false,
            ExportMenu::FORMAT_EXCEL_X => false,
        ],
    ]);
    ?>

    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'pager' => [
            'firstPageLabel' => '第一页',
            'lastPageLabel' => '尾页'
        ],
        'columns' => [
            ['class' => 'yii\grid\SerialColumn'],

            'gift.title',
            [
                'attribute' => 'out_trade_no',
                'enableSorting' => false,
            ],
            'gift.price',
//            'count',
            [
                'attribute' => 'count',
                'enableSorting' => false,
            ],
            'user.nickname',
//            'create_time:datetime',
            [
                'attribute' => 'create_time',
//                'value' => 'create_time:datetime',
                'value' =>
                    function ($model) {
                        return date('Y-m-d', $model->create_time);   //主要通过此种方式实现
                    },
                'filter' => DatePicker::widget([
                    'model' => $searchModel,
                    'attribute' => 'create_time',
                    'language' => 'zh-CN',
                    'clientOptions' => [
                        'autoclose' => true,
                        'format' => 'yyyy-mm-dd'
                    ]
                ]),
            ],
            [
                'attribute' => 'status',
                'enableSorting' => false,
                'value' => 'statusValue',
                'filter' => EduEnterOrder::attributeValue()['status']
            ],
            [
                'attribute' => 'total_fee',
                'enableSorting' => false,
            ],
//            'id',
//            'user_id',
//            'openid',
//            'gift_id',
//            'out_trade_no',
            //'total_fee',
            //'count',
            //'status',
            //'create_time:datetime',
            //'name',
            //'phone',
            //'address',
            //'logistics',
            //'logistics_fee',
            //'order_num',
            //'info',
            //'remark',
            //'style',

            ['class' => 'yii\grid\ActionColumn',
                'template' => '{view} {update}'
            ],
        ],
    ]); ?>
</div>
<?php
$script = <<< JS
    $(".pagination").append('&nbsp;跳转<input id="invalue" type="text" style="border-radius: 5px;outline: none;border: solid 1px #dddddd;width: 52px;height: 34px;text-align: center;" class="pane"/>页&nbsp;<button id="skip" class="btn btn-default skip ok"">确定</button>');
    
    $('#skip').click(function() {
        var page = $('#invalue').val();
        location.href = "index.php?r=edu-enter-order/index&page="+ page;
    });
JS;
$this->registerJs($script);
?>
